fixed function definition scope error