better code commenting added; code reformatted too