Added trap for database lock