Refactored code for building UDC index