refactor check error rather than resp