fixed a bug in calc_next_lvl.cc