added scoping for function declaration