computing S and teta...