Locking logic fixed