You might want to consider splitting this code in the ifs into their own methods, there is a lot going on here