refactor calculate

refactor calculate js and backend code