Updated functional to support fragments