fix api last page logic