fix pkg write bug