Inefficient but works.