refactored titleize method