fixng bugs with search+pagination logic