add weight*S calculation