cleaned up filtering and pagination