Added a lock in event callback