avoiding unnecessary calculation. calculation time is reduced to 93s from 260s