added edge cases to string processing method