new version with dynamic tables