fix line parsing function