updated code for the new document