Off by one error in chunk numbering, I am removing the complexity by turning it into a count query.