updated code added search function