Rewrite phone hack, now optimized to nlogn!