a simpler implementation using inlinecallbacks