added regex to properly display error messages