this is the version that doesn't have the precomputation function