fixed some bugs when printing and with stacking code