Added functionality for error handling