Optimize the logic of hide blocks.