fixed pagination (need to add history functions)