Add safe code prevent the farm_counter will be -1