merge pt\'s js code