renamed handler() to flat()