refactor the calculate class