Finish implementing search function