move this to the first line of the method and check that the id is not null