Extract some if conditions to methods so it's all more readable