added code for ex4