added comments at the top and removed extraneous code