Code Refactoring and updating library