added functions and scope