Ajs 7 refactor waitfordocumentready and