removes unnecessary timeout, proper type checking of onDOMLoad