Fixed bug in getFormats()

Occasionally, the API returns an array with multiple format types. The code was not written to handle that case. Now it is.