add some logging and correct small context changing mistake