hw5 added code for ex2