broaken again
new version of code to cal offsets in schedule buffer