Fixing application locking logic