first attempt at solving the problem