Implement Search correctly

Not tested and no test function written yet.