Faster way to filter out background