fix bug in calculate