Rename variables, make function to organize, add comments