added custom callback function for preview