better error/warning writing