problem 10: solved, but not in a DRY way