added some functions for forcomp assignment 6