add check when error occurs