Correct slicing.
Add check for empty title string.