I didn't read through the whole code, but if you say the problem is around the if() statements, then you are essentially assigning load to load. You might have meant "load == load" and "lock == lock", but that will always return true, because 2 always equals to 2.