new code for gap detection, based on pandas dataframes