Split out separate function for updating context