Updated search, trying to fix bugs and simplify it a little