Fixed delimiter for gradient(). Added if condition for gradient also.