Removed bool var locked, because it's not needed.