more DRY code. also use "with" instead of try/except
remove hard-coded string