some refactoring with addition of context