changed appendToBody to be correctly backward compatible