Refactored, includes case for non-alpha characters.