Added a pair of ifs to correct an exception in case that the flow number varies between samples