implemented batch version - not tested