rename some variables and reorganize the drawLines helper