slighty refactor solution to problem 89