big refactor.. finalise chain stack pattern. still pwd() with problem