Added callback function for scan function in JS