final functionality for Lab 6 with backwards working and comments added.