modified JavaScript snippet