Major refactoring to use java sdk
Refactor to remove duplicate codes
Change to using a refactored code