Convert script to a module

By adding the condition "if __name__ == '__main__' ", the script can now be used as a module in other python modules/scripts