added err value to callback function