Moved random num generator to index