refactor stack.