re-factor error action