count the number of cols instead of magic number