Refactored utility funcs