Code for prog3