Modified stack to throw exceptions and fixed bug with numItems variable