Help with flow selection order gives wrong item

Please advise what I am doing wrong?
In the accompanying flow, the intention is that a scene is started depending on the lux value. If the lux value is between 30-300, wk_schemer should be selected. However, wk_avond is selected first and only wk_schemer at the next trigger.

// Initialize messages to null
var msg1 = null;
var msg2 = null;
var msg3 = null;
var msg4 = null;

// Initialize context variables if not already defined
context.lux = context.lux || 0;

if (msg.topic == 'lux') {
    context.lux = msg.payload; // Store the payload in context.lux
}
var L = context.lux;

// Determine the setup value based on the lux value
if (L >= 600) {
    msg1 = { payload: { entity_id: "wk_uit" } };
} else if (L >= 300) {
    msg2 = { payload: { entity_id: "wk_dag" } };
} else if (L >= 30) {
    msg3 = { payload: { entity_id: "wk_schemer" } };
} else if (L >= 0 ) {
    msg4 = { payload: { entity_id: "wk_avond" } };
}

// Return the output messages
return [msg1, msg2, msg3, msg4];

Firstly, you need to use context.get and context.set to get/set context values. Although what you've done might currently work with memory based context, there is no guarantee that it will work in the future. And moving to another context library will also likely fail.

Then I would imagine that msg.payload does not actually contain a number. Probably contains a string number instead which means that your L value is 0.