fixing declaration order for compilers that require functions to be declared before their usage