update / refactoring to work correctly with the latest versions