added duplicate checking