add caterpillar main logic