correction in calculate function