Fixes a bug when migrating document handler