minor changes and addition of variables to track the application state