optimise baseband detect script