added code for exercise a2-4