minor locking change to minimize lock held time