move most of the logic for the MigrationTask from javascript to java