added lock to database