Fix logic issue with id