added calculate function