Fixed an if else block bug

Nested if / else blocks didn’t execute the correct blocks, that has now
been fixed.