use java.util.Stack instead of ArrayList