fixed the error catching warn function