fixed a bug that would cause mongodb duplicate key error