change gradient evaluation method with more effective algorithm
working on density evaluation logic