fixed global decl/func order