fix on line inversion
fixed minor bugs