copied from [pacman-4.1], and updated