fix handling of document exists
remove semicolons so not having them in the code throws syntax erors.