hw2- fixed gradient issue