added comments and cleaning up clode