our tweaks of the amazon sample code