refactor content detection