Added the beginning of conditional encoder logic