Changed old hpricot for nokogiri and refactored whole code