Finish Lecture2 class homework. Fixed bugs