wrapped in encapsulating function