Added duplicate error check