added repeat logic
fixing offsets