Added gradient check