4 ifs in a row. Is there a way we can make this require less nesting?