added fine grained locking