Updated code as per feedback from review using http://pareview.sh