refactoring for obtaining the context
usage of getContext function