Finished initial calc_Sws function