diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index b075e0c86b5b67bb20b1a440299f775eab310304..5750f328c1fcad71514aa87fab76dc7380b3676e 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1077,7 +1077,7 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
             st->user_bandwidth = value;
             if (st->user_bandwidth == OPUS_BANDWIDTH_NARROWBAND) {
                 st->silk_mode.maxInternalSampleRate = 8000;
-            } else if (st->bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) {
+            } else if (st->user_bandwidth == OPUS_BANDWIDTH_MEDIUMBAND) {
                 st->silk_mode.maxInternalSampleRate = 12000;
             } else {
                 st->silk_mode.maxInternalSampleRate = 16000;