Transfered code from sinatra-chassis