fix filtering calculation