code from notes and exercises