New JavaScript logic