Refactor lock service