this is tricky... please add some comments here about why this is necessary.