Fixed a potential bug in problem 27