using an array as a stack