Amend code to print objects without explicitly calling to_s method