have decided to trust git, finally implemented the alogirthm correctly I think