made some adjustments to callbacks to javascript