minimized js and added onStart and callback functions