split update_context into 2 methods to increase readability