refactoring the code for creating new set 'context'