working search function magic