modified tend in main.f90