Line_pos calculation bugfix