add duplicate entry detection and fix is_successful logic