Refactored the logic for making all first letters in each word upper case