added a safe wrapper for extension