replaced lock acquire/release by context manager ("with" block)