add calculate ws function