This seems wrong - you only added a single row for all changed medias. Also, note that you have to check change_medias if it is a GrlMediaAudio, GrlMediaBox or any other type of medias, we can't just go and add them one by one.