Add calculate function