Adding check for invalid ids