exercise from GOOS book