Modified to use dynamic table