removing bad JavaScript logic