Refactoring buildLineString as new method