[#2212] CID25988:

Added missing unlock, refactor to eleiminate redundant code