Fixed extra array item bug by trimming a string variable