fixed bug with referencing out-of-scope structures