refractored context initialisation