Added gradient function!