added document var to IIFE