write better js with scope and IIFE