fixed JS missing if else brackets