refactor (no speedup)