fix main flow