refactored several lockings