split out sameLine into own function