Logic changed and Readability improved

Changed the way the auto enrollment id selector code works, and changed "okid" to "usedid" so that the code is easier to understand.