commit main logic