finalised basics of EWS function