added S function