added check for uniqueness for codes