separated dom from math calculations and simplified column calculation