Added try_lock method
Small refactoring