changed algorithm for proper capitalization