Modified generateRandomPosition()