Remove dependency on sql_exist()