add removal of large dots and refactored code