fixed off-by-one in sum calculation and took out extraneous print statements