re-implement search function (current best: 1024)