Implemented status stack for better error handling