finish friend function