working pb3 code