move a largish block of code around to trick a GCC warning