Better working search function