A more elegant solution to left$ and right$.