Fixed handling of the case where an invalid PI code is used