optimize attaching Pueblo PB handler and fix a bug