added lock() and unlock()