added calculate finction