Added calculate function