Refactored some of the id code