performance enhancements: separate math and DOM steps