search function & minor fixes