Updated JS with new functionality