added mode E logic