This block should be:

if(lockLevel != 0)
    locklevel = ...
else
    lockLevel = 100;

The important distinction is the first if statement, presently this will always set the locklevel to 100