I should try to re-use a bit of code here because there's going to be a lot of these. Contributes to issue CURA-3497.