Fixed bug with lock