Refactored filtered.js