updated code to avoid deprecation warnings