Tried to use std::set to reduce the time spent on std::vector::push_backs