inital filtering code