finished writing and testing functions.