Code for cs533 assignment 4