error message handler (prints twice, needs fix)