added another function to filter out non overlapping masks. program is more or less complete