Improved the model to be resilient to switching app to background