modified to match source code downloaded from packtpub.com