cleaned up search code