refactored index filter a bit