caculate the result and add tests