fix bug of variable definition order