implementing an extend function