I see this code twice, maybe extract it to some method?