fixed sql command, added searching