The two methods looks quite similar. unify into a reusable method?