Incorperated changed CalcSws into the rest of the code