added rehash function and convert ddl gen to proc