Add check to avoid crash when running in iOS 7