simplify gradient code