fill out second half of the modified add function