fix bug in search function