fixed a bug to call the callback function properly