translated to ruby/sinatra