added another function for error handling