Have re-written the if else section, so that each string assignment can
only be done by one position in the index. Code still includes
commented-out old version of if else area.