Code for third lecture