get rid of foreach and filter