Fixed issue with invalid random max value