I don't know. I refactored this code from BlocklyApps to here. The function is hard to read and I'd rather not risk breaking it.