Add lock to prevent crash