Flatten function is better than ever