fixing bug with database search