added named functions and scoped functions