added java doc and refactored
added java doc and refactored