comments

added comments
added a little more error handling