refactoring and replace deprecated methods