fixing filtering infinite loop