rewrote methods with fewer copy operations