implementing scaler encoder