added functions for extracting positions of referred IDs