Speed up prune function