subboxpng: extract the cells code into function