move declaration to the top of the block; ref #1727