Refactored pygments function.