optimized and filter now works