fix bug 2817: move use of variable after its definition.