update/improve util functions from the prelude distro