Added lock(locker) for thread safety