fix ordering bug with function definition