Fixed scope issue with callback