Better handling of invalid ids