Make function return variable from within nested "IF" routines

Thanks for this Hugo!

The approaches really helped me out :slight_smile: