added logic to remove all unwanted elements that are too small