adding helper code for Assignment 6 NOT DONE