Final Code

Final code including all comments