throw error if invalid input; prevent duplicates