extracting ids correctly