Another attempt at fixing DeprecationWarning