Fix bug for incorrectly written list of chunks