added callback function for selection event