My attempt at a solution