stack design pattern implementation