Remove extra commas that are at the end of the last element in arrays