Refactored create line method