Maybe add a comment to explain this gigantic if statement?