Funtion extract data