Implemented homework 6. Ready for students.