Added checks for illegal id values