fix stack and tree