Improved random_map