Using Set instead of Array, Set is much faster than Array to search an element