modified insert method for dynamic tables