fixed issue with entities at end of text