Rewrite the replace function to work better but it's less efficient

7 jobs for master in 25 seconds (queued for 2 seconds)