I don't like the duplicated logic here.