Variations api loop fix

See #3088