Refactor code, add Twig filter