please add a few comments which explains the purpose of the coarse_flag, coarse_interval and fine_interval variables.