simplify gradient logic