this all shares some code can we extract that in util methods?