version that works with multiple heritance