Edited search function, but still not working properly