Update IDs based on position