Fix ridiculous stacked if statements on line 576