Updated the flatten and mosaic steps