finished assign2 functions