YJ- implemented stack-outputing