Got rid of unnecessary intermediary variables and an iterative loop that served no purpose