refactored appcontext