copying willis code from session 4