Added custom error message functionality