Refactored addressToScript for clarity