It seems like this logic should be split into two separate methods