added scope stack and function calls