better line build logic