added precomputation