insanely inefficient implementation