improved example with working fix