bugfix when inserting empty document