Crazy fucking if/else structure