major rework of substitution engine