Refactor distributed lock