recursive implementation for creating variations