adapted for newer library versions