faster (but still naive) implementation and benchmark