replaced iife's with function declarations and some if statements. reads much cleaner.