combined 2 for loops into 1
combined 2 for loops into 1
removed unused function