I fixed the problem. It was expecting that after the function is executed it's value will be changed to either a 1 or a 0. But then I called the function to execute the code and use the returned value immediately.
I was thinking of it the wrong way, it actually returns a value and not change the function's value itself