Lecture 8 with some bug