stack implementation (initial code)