resolve return vars in the correct context