Changes and modularise some part of code. Added checkLesson function