bug fixed: error returned from function calculate