added finally for lock release
code reformat per request