Refactor function to support other commands
Add command min for filter on minimum length
Add command len for filtering on exact length