add condition in app.rb to check for duplicate history