implemented S2 calculation