Refactored session filtering