Refactored the code as per PMD and added the logger