moving if statements to contain outer divs