avoiding globals and fixing a bug with all_block