Fixed bug for based on lecture 7