fixing gradient issue