adding helper code for Assignment 6