handled unloading of media in a better way