Added optional callback function