Use local var for nodeSelection + if-else instead of switch. Remove redundant checks in RandomSource