remote is added to git repo if one exists
cleaned up the code a bit and added comments