The logic is different here. It could have gone to a separate function, but I saw so many more important things that could have been improved...