refactor sentence detector