twig extension refactored