fix "function used before define"