Making the getContext() method more flexible