now using locks for concurrency safety