fix bug in line updating function