finished EWS function