added the code for exercise b1