changed 'flatten' to point-free per StackOverflow post answer