Could probably extract a method here that could also be used below.