shamelessly copied in standard import.io callback function