moved smart-flat to the letfn for better readability