Put the logic of mosaic line to another file.