perform small refactor on solution to problem 491