more improvements to titlecase function