rewrite stack.h and test it