Reduce complexity

Reduces code complexity as pointed out by seniolabs insights