Improved organization of the createLine function