works, but slow and data structure is terrible