cleaned up search controller code