refactoring and fix deprecated library