re-implement https://github.com/popuparchive/pop-up-archive/pull/515/files
manually merge 302e70c