Code Reduction

Implemented loops + variables to reduce lines of code and computations.