move code around to fix some gcc error that doesn't occur with real compilers