updating lecture8.R