Added duplicate error handling