Bug fix with root type checking