added if statement to get rid of undefined index search warning