Refactored per Keith's comments