Refactor stack to separate object