added javascript conditionals