Fix id logic