fixed it so it works for same-line and different-line