added needed libraries
upgraded search algorithm