code for 3rd lecture