simplified the checkgrad logic somewhat