checkgrad was changing parameters