you should surround lock and everything, you want to protect, with { }