Added better search and sql injection prevention to search function