logic for locks