Fix to callback function calls

fix to callback function call, removed deprecated call to writeJavascript