Added comments in code explaining the variables and functions.