refactor stack design