bug #664 - fix lock

https://gist.github.com/rgatkowski/ac8409e208543463627f