removed some duplication, showing z as accumulator