improved openLock() and added checkMoving()