refactor build-context-list functionality