finished return by ref and fixed cout.