fix a bug in generating lines