Further optimization of append/prepend methods