Solve problem 5 and it's so ugly