Modified TryFormatInstance implementation to be consistent with the client-side implementation