added comments, cleaned up