filter by popularity
minor robustifying
refactoring