Ported https://github.com/kcl-ddh/digipal/commit/22ae5572c0c8d98f1b92f87cb8e5750fabbf212d to staging.