Fix pinning logic