change appendfile method