Reduced size of code in calculate.c