I have refactored the template filters a bit