Updated for-loops with equivalent functions.
Cleaned up references.
Used function chaining instead of string concatenation.