Replacing values in array on click