Flatten function definition