Updated the hook to save custom fields