New function that add_action then remove_action then add_action that causes double revisions

I'm having a problem with a function I have on my theme's functions.php file. It counts the number of posts, assigns a number in a custom field then adds that custom field as a slug to the post. The problem I have is the code I have uses 'add_action' then 'remove_action' then 'add_action' again. This is to stop infinite loops but the problem I'm having is that it causes double revisions on the post and a plugin I'm using to copy posts from my main site to another site in my WordPress network causes double posts on the copied site.

function updateNumbers( $post_id ){
if ( ! wp_is_post_revision( $post_id ) ){
global $wpdb;
$querystr = "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ";
$pageposts = $wpdb->get_results($querystr, OBJECT);
$counts = 0 ;
if ($pageposts):
foreach ($pageposts as $post):
add_post_meta($post->ID, 'incr_number', $counts, true);
update_post_meta($post->ID, 'incr_number', $counts);
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'updateNumbers');
// update the post, which calls save_post again
wp_update_post(array('ID' => $post->ID,'post_name' => get_post_meta($post->ID,'incr_number', true)));
// re-hook this function
add_action('save_post', 'updateNumbers');
add_action('save_post', 'updateNumbers');