Solve problem 11 -- needs refactor