keep refactoring to encapsulate app state