updated parser api to handle document passed in