Extract context generator routine