use grid instead of table; tweak grid calculations