added check gradient method