Fix duplicate error check