added comments and formatted source