fixed index functions and added search