Code for lab 2