fixing pagination upon loading the first time