this is really the code for lec4.