pass object by value through function