Refactored the fragments
added javadoc