getting rid of potential sql error in filtering selects