add onComplete function