dynamic implementation of stack