fixed dumb error in and cleaned up search code