finished writing the function