pulled close out of function back to script, some formatting