Refactor code and change data structure to TreeSet instead of ArrayList