fix r\/w bug