almost finished, ready for code review