updated to check curent state of lock