code cleanup for embedded document