adapted the code to work in master version