added code from EC