added comments and made minor formatting changes