Fixed bug in migration code