find first flag of data frame. not proud of the logic