rewrote and clarified comments