Added throwing and displaying all three conditions: success, duplicate and error