much improved floodfill thanks to @potch