Some refactoring on the detect dawn script