Added more of my comments in order to illustrate thought process.