added 'if' statement so can run as a stand-alone