code example for flatstack