finished writing functions