adding sql and fixing search form