fixed version of code so that it also compiles on 3.10 and earlier