functions for hw4