simplified generateSerial (finally)