refactoring for deprecation warning