refactor ftdetect