Fix logical issue in API