Refactor. Problem 31 added.