improve Reply.write function