Implemented type checking and checking for duplicates