reversed order of checking to work around rdar://14952597

fixes #595