Improved the logic of the data 'callback' to parent scope