Updated JS with limit option