added comments, cleaned up code
added alternate code commented out