First attempt at Problem3 - performance needs to be imporoved