Edited js to remove images before appending new ones