generalized the zip implementation.