Classic software filtering method C, algorithm