checking out new approach with precomputing