Use three specialised functions instead of REPLACE-UB8.