rewrite StackImplementation