calculate implementation