Main coding