changed array_pop to unlink the last img for undo