Added comments and changed layout for easy modification and future use.