Added javadoc
Refactored Code