implemented dynamic table handling in database