added formular for gradient