Moved re-usable function to a utilities module.