moved jquery if else to head