Changed function scoping