extracted logic to gem