Fixed a bug in part 6 code.