Complete refactor. Used For loop for efficiency