Refactor search

simplify cmd_search function which does both command parsing and execution