refactor code for readability and remove code duplication
refactor code for readability and remove code duplication

fedora-conary/conary,fedora-conary/conary,fedora-conary/conary,fedora-conary/conary,fedora-conary/conary