added precalculation