Complete ex2_reg

Finally completed the Programming Exercise 2