New signature for writeAndWait method and callback