clean up and fixed ID-check