added comments, and consistent coding