For the sake of reusability, this function could live in some place under utilities