Solution 24 Sped Up

Sped up but still needs refactoring