Problem with friend function fixed. Use of public method is applied