Would be easier to review if the parameters were in a consistent order - unless I've misunderstood..  Here it is prefix before cluster, the function above it is cluster before prefix.