another slight optimization
solution to problem 6