Code adjusted after basic implementation of sync2