Pretty sure correct but slow soln