Code written for COMP 775 at the University of North Carolina at Chapel Hill