@sipa I've refactored the function a bit do prevent the strange style anywhere and make it easier to read