improve calculate lowest_m & best_k