add search function and lot of fixes