Borrowed heavily from Louis Whitcomb's course at JHU