(IMPROVE) Implement semi-colon and function scoping and graceful exits