added new procedure to migrate from temp tables