we should move that to a separate func as it is likely to get reused.