PERF: re-ordered if statements, made into exclusive checks