fixed all functions except for frame differencing