Code for assigment 4a