Refactored getInstance method and updated the javadoc