problem 18, no magic numbers