modify code remove unnecessary comments and spaces and add java doc