Fixed bug in search function