Refactored

Sped up solution 10 and made it easier to read