Updated with professor's code.