changed appendToBody to be correctly backward compatible

changed appendToBody to be correctly backward compatible