refactored to provide nested context