refactored lock aquiring