refactor title_case function