Editing search function

Fixing it and tweaking it