code for reassignment 2