Simplified the generateRandomString method